<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="{$Assets}layui/css/layui.css">
    <style type="text/css">
.layui-table-body{
    overflow: hidden;
}
    </style>
</head>
<body>
{include file="public/header" /}


<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>权限设置</legend>
</fieldset>
<div style="width: 98%;margin:0 auto;">
<table class="layui-table" lay-data="{ url:'masterall', page:true, id:'user'}" lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{field:'id', width:100, sort: true,}">ID</th>
        <th lay-data="{field:'master', width:130}">名称</th>
        <th lay-data="{field:'type',width:130}">类型</th>
        <th lay-data="{field:'addtime',width:180}">添加时间</th>
        <th lay-data="{field:'logintime',width:180}">最近登陆</th>
        <th lay-data=""></th>
        <!--<th lay-data="{field:'ChangePass', width:120}">/th>-->
        
        <th lay-data="{width:200, align:'center', toolbar: '#barDemo'}"></th>
    </tr>
    </thead>
</table>
</div>
<script type="text/html" id="barDemo">
{{#  if(d.id != 1){ }}
    <a class="layui-btn layui-btn-xs" lay-event="edit">设置</a>
{{#  } }}

</script>












<script src="{$Assets}layui/layui.js?t=1515376178709"></script>
<script>
layui.use('table', function(){
  var table = layui.table;
  
  //
  table.render({
    elem: '#LAY_table_user'
    ,url: 'allproduct'
    ,cols: [[
      {checkbox: true, fixed: true}
      ,{field:'id', title: 'ID', width:80, sort: true, fixed: true}
      ,{field:'title', title: '标题'}
      ,{field:'addtime', title: '添加时间', sort: true, width:180}
      ,{field:'updatetime', title: '更新时间', sort: true, width:180}
      ,{field:'issue', title: '作者', width:100}
      ,{fixed: 'right', width:178, align:'center', toolbar: '#motion'}
    ]]
    ,id: 'prolist'
    ,page: true
 
  });


  table.on('tool(demo)', function(obj){
    var data = obj.data;
    if(obj.event === 'edit'){

      layer.msg('11');
      layer.open({
        type: 2 //iframe
        ,title: '编辑权限'
        ,area: ['600px', '70%']
        ,shade: 0.8

        ,maxmin: true
        ,offset: 'auto'
        ,content: "{:url('user/set_power')}?id="+data.id
        ,zIndex: layer.zIndex 
        ,success: function(layero){
          layer.setTop(layero); 
        }
      });


    }

  });

  var $ = layui.$, active = {
    reload: function(){
      var demoReload = $('#prolist');
      
      //
      table.reload('testReload', {
        page: {
          curr: 1 // 1 
        }
        ,where: {
          key: {
            id: demoReload.val()
          }
        }
      });
    },
    delproducts: function(){ //
      var checkStatus = table.checkStatus('prolist')
      ,data = checkStatus.data;
      delspro=JSON.stringify(data);

                  $.ajax({
                        type:"POST",
                        url: "{:url('product/delspro')}",
                        data:{data:delspro},
                        dataType:"json",

                        success:function(ret_datas){
                            if(ret_datas==1){
                                layer.msg('!');
                            }else if(ret_datas==99){
                                layer.msg('');
                            }else{
                                layer.msg(ret_datas);
                            }
                            setTimeout("location.reload();",1000);
                        }
                    });


    },
    addproduct:function(){


      //
      layer.open({
        type: 2 //iframe
        ,title: '添加产品'
        ,area: ['90%', '90%']
        ,shade: 0.8

        ,maxmin: true
        ,offset: 'auto'
        ,content: "{:url('product/addproduct')}"
        ,zIndex: layer.zIndex //1
        ,success: function(layero){
          layer.setTop(layero); //2
        }
      });


    },

  };
  
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>
{include file="public/footer"/}

</body>
</html>